|
|
|
|
|
|
|
Of course, just drawing a text box or other control does notbind it to the database. You first have to set two more properties. |
|
|
|
|
|
|
|
|
Using a Bound Control to Display Data |
|
|
|
|
|
|
|
|
For a bound control to work with the data from a recordset, you must bind the control to the Data control that represents the recordset (recall that you've already read how to bind the Data control to data) and to a specific field within that recordset. The first step is to set the bound control's DataSource property. Setting this property establishes a connection between the bound control (that is, a text box) and the Data control. The next step is to set the DataField property of the bound control, which links it to a field in the recordset to be displayed. As you continue working through the BIBLIO example that you began earlier, you'll learn how many of these bound controls work. |
|
|
|
|
|
|
|
|
Setting the DataSource Property |
|
|
|
|
|
|
|
|
To set the DataSource property, select it from the Properties window for your control. Click the arrow to the right of the input area to see a list of all the Data controls on the current form. To set the DataSource property, select one of the controls from the list. Figure 25.6 shows this procedure. |
|
|
|
|
| |
|
|
|
|
Instead of dropping down the list, double-click the DataSource property to step through the available Data controls. |
|
|
|
|
|
|
|
|
|
|
Figure 25.6
The DataSource property sets up the binding
between a dataaware control and a Data control. |
|
|
|
|
|
|
|
|
Setting the DataField Property |
|
|
|
|
|
|
|
|
Although the DataSource property tells the bound control from which Data control to retrieve data, you still need to tell the bound control what specific data to retrieve. You do so by setting the DataField property. This property tells the control which field of the recordset will be handled by this bound control. |
|
|
|
|
|
|
|
|
To set the DataField property of the control, select the DataField property from the Properties window, click the arrow to the right of the input area, and select one of the fields from the displayed list. The list includes all available fields from the recordset defined in the specified DataSource (see Figure 25.7). |
|
|
|
|
|